﻿namespace DBMock.Builders
{
    /// <summary>
    /// 字符串挑选builder
    /// </summary>
    public class StrPickerBuilder : Builder
    {
        private string[] source; //源

        /// <summary>
        /// 初始化StrPickBuilder
        /// </summary>
        /// <param name="seed">随机数种子</param>
        /// <param name="source">源</param>
        public StrPickerBuilder(int seed, string[] source)
            : base(seed)
        {
            this.source = source;
        }

        public override object Build()
        {
            if (source == null || source.Length == 0)
                return string.Empty;

            int max = source.Length;
            return source[random.Next(max)] ?? string.Empty;
        }
    }
}
